/*******************************************************************************
tcsproc.inl
     
*******************************************************************************/
#ifndef _TCSPROC_INL_
#define _TCSPROC_INL_


inline TCHAR _towupper(TCHAR tc)
{
	if(tc >= L'a' && tc <= L'z')
	{
		tc = L'A' + (tc - L'a');
	}
	return tc;
}

inline TCHAR _lower(TCHAR tc)
{
	if(tc >= _T('A') && tc <= _T('Z'))
	{
		tc = _T('a') + (tc - _T('A'));
	}
	return tc;
}

inline TCHAR _upper(TCHAR tc)
{
	if(tc >= _T('a') && tc <= _T('z'))
	{
		tc = _T('A') + (tc - _T('a'));
	}
	return tc;
}


inline LPCTSTR _tcsistr(LPCTSTR pSrc, LPCTSTR pDst)
{
	LPCTSTR x;
	LPCTSTR y;
	LPCTSTR c;
	
	x = pSrc;
	
	while(*x)
	{
		if(_lower(*x) == _lower(*pDst))
		{
			y = x;
			c = pDst;
			while(*y && *c && _lower(*y)==_lower(*c))
			{ 
				c++;
				y++; 
			}
			if(!*c)
				return (LPTSTR)x;
		}
		x++;
	}
	return NULL;
}

inline LPTSTR _tcscpyA2T(LPTSTR pDst, LPCSTR pSrc)
{
	LPTSTR pRet = pDst;
	
	while(*pSrc)
	{
        *pDst++ = (TCHAR)*pSrc++;
	}
	*pDst = 0;
	
	return pRet;
}


inline LPTSTR _tcscatA2T(LPTSTR pDst, LPCSTR pSrc)
{
	LPTSTR pTmp = pDst;
	
	while (*pTmp)
	{
		pTmp++;
	}
	
	while ((*pTmp++ = (TCHAR)*pSrc++) != 0)
	{
		;
	}
	
	return (pDst);
}

inline int _tcsnicmpA2T(LPCTSTR pSrc, LPCSTR pDst, int nCount)
{
	int ret = 0;
	while(nCount > 0 && ret == 0 && *pDst)
	{
		ret = _towupper(*pSrc) - _towupper((TCHAR)*pDst);
		pSrc++;
		pDst++;
		
		nCount--;
	}
	
	if (ret < 0)
	{
		ret = -1 ;
	}
	else if (ret > 0)
	{
		ret = 1 ;
	}
	
	return ret;
}


#endif //_TCSPROC_INL_
